package eShopDemo;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

@ManagedBean
@ApplicationScoped
public class Catalog {

	private List<Product> products = new ArrayList<Product>();

	public Catalog() {
		products.add(new Product("p01", "Pencil", 1.2));
		products.add(new Product("p02", "Eraser", 2.0));
		products.add(new Product("p03", "Ball Pen", 3.5));
	}

	public List<Product> getProducts() {
		return products;
	}

	public Product findProductById(String pid) {
		for (Product p : products) {
			if (p.getPid().equals(pid)) {
				return p;
			}
		}
		return null;
	}

}
